<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
    <title>企业实名认证</title>
    <link rel="stylesheet" href="../../css/reset.css" />
    <style>
        body {
            width: 100%;
            background-color: #fff;
            font-size: 0.26rem;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            font-family: Helvetica;
            color: #333333;
            height: auto;
        }

        .uppicture {
            width: 100%;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            padding-top: 0.32rem;
        }

        .uppicture div {
            margin-bottom: 0.35rem;
        }

        .force {
            width: 5.6rem;
            height: 4.68rem;
            background: rgba(249, 246, 249, 1);
            border-radius: 0.1rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .nextbutton {
            width: 6.84rem;
            height: 0.9rem;
            line-height: 0.9rem;
            text-align: center;
            background-color: #ffd203;
            outline: none;
            border: none;
            border-radius: 0.1rem;
            margin-left: calc((100% - 6.84rem) / 2);
            font-size: 0.28rem;
            margin-bottom: 0.5rem;
        }

        .showText {
            font-size: 0.27rem;
            font-family: PingFang SC;
            font-weight: 400;
            color: rgba(173, 173, 173, 1);
            margin-top: 0.3rem;
        }

        .clientPicture {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
        }

        .clientPicture>div {
            width: 5.6rem;
            height: 3.44rem;
            background: rgba(249, 246, 249, 1);
            border-radius: 0.1rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .tips {
            font-size: 0.26rem;
            font-weight: 400;
            color: #181818;
            margin-bottom: 0.32rem;
        }
    </style>
</head>

<body>
    <div class="uppicture">
        <p class="tips">请上传企业营业执照</p>
        <div class="force" data-flag="idCardfront">
            <img src="../../image/iconzhizhaox.png" style="width:3.46rem;height: 3.2rem;" id="idCardfront"
                data-path="" />
            <b class="showText">
                上传企业营业执照正面
            </b>
        </div>
        <div class="clientPicture" style="margin-top: 0.14rem;">
            <p class="tips">请上传委托人身份证正反面</p>
            <div class="clientPositive" data-flag="clientPositive">
                <img src="../../image/zhengmianx.png" style="width:3.12rem;height: 1.96rem;" id="clientPositive"
                    data-path="" />
                <b class="showText">
                    上传身份证正面
                </b>
            </div>
            <div class="otherSide" data-flag="otherSide">
                <img src="../../image/fanimianx.png" style="width:3.12rem;height: 1.96rem;" id="otherSide"
                    data-path="" />
                <b class="showText">
                    上传身份证反面
                </b>
            </div>
        </div>
        <div>
            <p>
                请确保照片的内容完整并清晰可见，<br />
                仅支持JPG和PNG图片格式，图片大小小于2M。
            </p>
        </div>
    </div>
    <button class="nextbutton">提交</button>
</body>

</html>
<script src="../../script/autosize.js"></script>
<script src="../../script/jquery_three_two_one.js"></script>
<script src="../../script/app.js"></script>
<script>
    apiready = function () {
        var app = new APP();
        var account = app.getAccount();
        var imgWidth = app.W * 0.85;
        var imgHeight = imgWidth;
        var userName = api.pageParam.userName;
        var userCardNumber = api.pageParam.userCardNumber;
        var clientName = api.pageParam.clientName;//企业委托人姓名
        var clientIdNum = api.pageParam.clientIdNum;//身份证号
        var typeChooseNew = "idcard";
        var goMyPage = api.pageParam.goMyPage;
        var goAddMoney = api.pageParam.goAddMoney ? true : 'false';
        function openPirtrue(thiz, picname) {
            if (picname) {
                imgHeight = app.accDiv(imgWidth, 1.58);
            }
            app.sheet({
                buttons: ["拍照", "相册"],
                cancelTitle: "取消"
            }, function (ret, err) {
                app.trigger("selectPic");
                var index = ret.buttonIndex;
                app.log("index", index);
                if (index == 1) {
                    //拍照
                    app.shootPic(function (ret, err) {
                        app.log("shoot", ret);
                        // 图片裁剪
                        if (ret && ret.data) {
                            app.openImgHandle({
                                type: typeChooseNew,
                                flag: $(thiz).data("flag"),
                                srcPath: ret.data,
                                dimension: [imgWidth, imgHeight]
                            });
                        }
                    });
                    return;
                }
                if (index == 2) {
                    //相册
                    app.getPic(function (ret, err) {
                        // 图片裁剪
                        if (ret && ret.data) {
                            app.log("get", ret);
                            app.openImgHandle({
                                type: typeChooseNew,
                                flag: $(thiz).data("flag"),
                                srcPath: ret.data,
                                dimension: [imgWidth, imgHeight]
                            });
                        }
                    });
                }
            });
        }
        $(".force").click(function () {
            var thiz = this;
            openPirtrue(thiz);
        });
        $(".clientPositive").click(function () {
            var thiz = this;
            openPirtrue(thiz, "idcard");
        });
        $(".otherSide").click(function () {
            var thiz = this;
            openPirtrue(thiz, "idcard");
        });
        app.listen("compress_image_success", function (ret, err) {
            app.log("压缩事件chankan", JSON.stringify(ret));
            if (ret.value.flag && ret.value.imgUrl) {
                var retCopy = ret;
                app.uploadImg(ret.value.imgUrl, function (ret) {
                    if (ret.code == 200) {
                        var vupImgHttpUrl = ret.data.files;
                        $("#" + retCopy.value.flag).data("path", vupImgHttpUrl.path).attr("src", vupImgHttpUrl.url);
                    } else {
                        app.toast(ret.message);
                    }
                })
            }
        });
        $(".nextbutton").on("click", function () {
            if (!$("#idCardfront").data("path")) {
                app.toast("请上传企业执照");
                return;
            }
            if (!$("#clientPositive").data("path")) {
                app.toast("请上传身份证正面");
                return;
            }
            if (!$("#otherSide").data("path")) {
                app.toast("请上传身份证反面");
                return;
            }
            app.ajax({
                param: {
                    method: "post",
                    url: app.ajaxUrl + "member/authenticate",
                    data: {
                        values: {
                            token: account.token,
                            name: userName,
                            id_num: userCardNumber,
                            qy_id_card: clientIdNum,
                            qy_name: clientName,
                            id_photo_1: $("#idCardfront").data("path"),//企业证件照
                            id_photo_2: $("#clientPositive").data("path"),//企业用户：身份证正面
                            id_photo_3: $("#otherSide").data("path"),//企业用户身份证反面
                            type: 5
                        }
                    },
                    callback: function (ret, err) {
                        app.log("auth", "提交返回：" + JSON.stringify(ret));
                        if (ret.code == 200) {
                            // 发送认证成功提交成功消息
                            if (goAddMoney == true) {
                                app.toast('提交成功');
                                app.theart(500, function () {
                                    app.toWin('littlemoneyrecharge_headerwin');
                                });
                                return;
                            }
                            app.trigger("auth_commit_success");
                            app.toast("上传成功");
                            if (goMyPage == true) {
                                app.openWin({
                                    name: "safetyset",
                                    url: app.hd + "my/safetyset.html",
                                    pageParam: {
                                        goMyPage: true
                                    },
                                    slidBackEnabled: false
                                })
                            } else {
                                app.toWin("safetyset");
                            }

                        } else if (ret.code == 0 && ret.statusCode == 500) {
                            app.toast("网络链接失败")
                        } else {
                            app.toast(ret.message);
                        }
                    }
                },
                extra: {
                    isflower: true
                }
            });
        });
        app.listen("commit_successful", function () {
            app.closeW();
        });
        app.headerMap();
    };
</script>